package com.xunyun.kotlinwc.network.exception

import io.reactivex.functions.Consumer
import java.lang.Exception

/**
 * @author gl
 * @date 2021/9/8
 * @desc
 */
abstract class  ErrorConsumer :Consumer<Throwable> {
    @Throws(Exception::class)
    override fun accept(throwable: Throwable?) {
        val ex: ApiException = if (throwable is ApiException) {
            throwable
        } else {
            ExceptionUtil.handleException(throwable)!!
        }
        error(ex)
    }

     abstract fun error(apiException: ApiException?)
}